package 集合;

import org.junit.Test;

import java.text.SimpleDateFormat;
import java.util.*;

public class JAVA {
    public static void main(String[] args) {

//        数组
//        List<String> arr = new ArrayList<String>();
//        arr.add("1");
//        arr.add("2");
//        arr.add("3");
//        arr.set(1,"9");
//        for (int i=0; i<arr.size(); i++){
//            System.out.println(arr.get(i));
//        }
//        System.out.println(arr.get(0));

        Map<String,String>  m  = new HashMap<String,String>();
        m.put("1","A");
        m.put("2","B");
        m.put("3","C");
        m.put("4","D");
        Set keyset = m.keySet();
        for (Object key :keyset) {
            System.out.println(key+"-"+m.get(key));
        }

//        增强型for循环   底层实现也是迭代器   简化版的迭代器  快捷键 I
        for (Map.Entry E : m.entrySet()){
            System.out.println("map key:"+E.getKey()+" "+"map value:"+E.getValue());

        }
        Collection value = m.values();
        System.out.println("直接取出value");
        for (Object val :value) {
            System.out.println(val);
        }

//        泛型    迭代器快捷键itit
        Iterator<Map.Entry<String,String>> I = m.entrySet().iterator();
        while (I.hasNext()){
            Map.Entry<String,String> entry = I.next();
            System.out.println("map key:"+entry.getKey()+" "+"map value:"+entry.getValue());
        }
    }
    @Test
    public void data(){
//        日期函数
        Date date = new Date();
        String D = String.format("%tY"+"年"+"%tm"+"月",date,date);
        System.out.println(D);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String string = new SimpleDateFormat("yyyy-MM-dd").format(new Date()).toString();
        System.out.println(string);
    }
}
